﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccess;
using System.Web.Security;
public partial class Admin_EditProvince : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
       
    }
   
    protected void BtnEdit_Click(object sender, EventArgs e)
    {
        
        SubSonic.Query Sq = TblProvince.CreateQuery();
        Sq.QueryType = SubSonic.QueryType.Update;
        Sq.AddUpdateSetting(TblProvince.Columns.Code, Txcode.Text);
        Sq.AddUpdateSetting(TblProvince.Columns.ProvinceName, Txpro.Text);
        Sq.WHERE(TblProvince.Columns.Id, SubSonic.Comparison.Equals,Session["Province"]);
        Sq.Execute();
        GrdProvince.DataBind();
        LblSuccess.Text = "ویرایش با موفقیت انجام شد";
    }



    protected void Drpro_SelectedIndexChanged(object sender, EventArgs e)
    {
      
    }
    protected void GrdProvince_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int Select=Convert.ToInt32(e.CommandArgument);
        int ProvinceId= Convert.ToInt32(GrdProvince.Rows[Select].Cells[0].Text);
        Session["Province"] = ProvinceId;
        switch (e.CommandName)
        { 
            case "Edit":
            TblProvince p = new TblProvince();
            p = TblProvince.FetchByID(ProvinceId);
            Txpro.Text = p.ProvinceName.ToString();
            Txcode.Text = p.Code.ToString() ;
            break;
        }
    }
    protected void GrdProvince_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GrdProvince.EditIndex = e.NewEditIndex;
        //Bind data to the GridView control.
        GrdProvince.DataBind();
    }
}